package com.lean.android.adsdk

import android.app.Application
import com.lean.android.ad.core.AdSdk
import com.lean.android.ad.core.config.AdConfig
import com.lean.android.ad.core.config.AdParamsProvider
import com.lean.android.ad.core.config.AppInfoProvider
import com.qmuiteam.qmui.arch.QMUISwipeBackActivityManager
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject

class AdInitial : KoinComponent {

    private val appInfoProvider by inject<AppInfoProvider>()

    private val adParamsProvider by inject<AdParamsProvider>()

    private val umengKey = getKoin().getProperty("umengKey", "")


    companion object {
        val OAID_PEM = "com.csxx.cbrowser.cert.pem"
    }

    fun init(app: Application) {
        AdSdk.debug = true
        AdSdk.init(
            app, AdConfig(
                appInfoProvider = appInfoProvider,
                adParamsProvider = adParamsProvider,
                channelInfoProvider = ChannelInfoProviderImpl(), //for test
                splashAdView = SplashAdViewImpl(),
                rewardCustomFloatView = RewardCustomFloatViewImpl(),
                accessPem = OAID_PEM,
                umengAppKey = umengKey
            )
        )

        QMUISwipeBackActivityManager.init(app)
    }

}